package com.gxa.controller.yhy.Patient;


import com.gxa.common.R;
import com.gxa.common.Status;
import com.gxa.service.PatientReportService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@Api(value = "患者报表功能",tags = "患者报表功能API")
@RequiresRoles(value = {"超级管理员","院长","主任","秘书","助理"},logical = Logical.OR)
@RequestMapping("/patient/report")
public class PatientReportController {

    @Autowired
    PatientReportService patientReportService;

    @RequestMapping(value = "/findReportList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "患者报表接口",notes = "患者报表接口",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code = 200, message = "查询成功"),
            @ApiResponse(code = 400, message = "代表参数格式不对"),
            @ApiResponse(code = 404, message = "代表找不到此请求"),
            @ApiResponse(code = 500, message = "代表后端代码出现异常"),
    })
    /**
     * 查找患者报表信息
     */
    public R findReportList(){

        R<Object> r = new R<>();
        List patientReportList = patientReportService.getPatientReportList();
        if (patientReportList.size() >0) {
            r.fromStatus(Status.SUCCESS);
            r.setData(patientReportList);
        }else {
            r.fromStatus(Status.SYSTEM_ERROR);
        }
        return r;
    }

    @RequestMapping(value = "/findReportArea",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "患者报表区域",notes = "患者报表区域接口",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code = 200, message = "查询成功"),
            @ApiResponse(code = 400, message = "代表参数格式不对"),
            @ApiResponse(code = 404, message = "代表找不到此请求"),
            @ApiResponse(code = 500, message = "代表后端代码出现异常"),
    })
    public R findReportArea(){
        R r = new R();

        List patientReportArea = patientReportService.getPatientReportArea();

        if (patientReportArea != null) {
            r.setCode(200);
            r.setMsg("success");
            r.setData(patientReportArea);
        }else{
            r.fromStatus(Status.SYSTEM_ERROR);
        }
        return r;
    }


    @RequestMapping(value = "/findReportFollow",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "患者报表跟进",notes = "患者报表跟进接口",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code = 200, message = "查询成功"),
            @ApiResponse(code = 400, message = "代表参数格式不对"),
            @ApiResponse(code = 404, message = "代表找不到此请求"),
            @ApiResponse(code = 500, message = "代表后端代码出现异常"),
    })
    public R findReportFollow(){
        R r = new R();

        List patientReportFollow = patientReportService.getPatientReportFollow();

        if (patientReportFollow != null) {
            r.setData(patientReportFollow);
            r.fromStatus(Status.SUCCESS);
        }else{
            r.fromStatus(Status.SYSTEM_ERROR);
        }

        return r;
    }



    @RequestMapping(value = "/findYearReport",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "患者年度报表",notes = "患者年度报表接口",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code = 200, message = "查询成功"),
            @ApiResponse(code = 400, message = "代表参数格式不对"),
            @ApiResponse(code = 404, message = "代表找不到此请求"),
            @ApiResponse(code = 500, message = "代表后端代码出现异常"),
    })
    public R findYearReport(){

        return patientReportService.getYearReport();

    }


}
